﻿<%@ WebHandler Language="C#" Class="SYS_User_sel" %>

using System;
using System.Web;
using System.Web.Script.Serialization;
using System.Data;
using System.Collections.Generic;
using System.Web.SessionState;

public class SYS_User_sel : IHttpHandler,IRequiresSessionState {
    sqlhelp sql = new sqlhelp();
    SYS_Userresult result = new SYS_Userresult();
    string str = "";
    DataTable dt = new DataTable();
    List<SYS_User> SYS_UserList = new List<SYS_User>();
    public void ProcessRequest (HttpContext context) {

        try
            {
                if (context.Session["comid"] == null)
                {
                    result.code = "-1";
                    result.msg = "用户未登录";
                    unit.send(context, result);
                    return;
                }

                string StoreId = context.Session["comid"].ToString();
            
                result.code = "1";
                string where = "and StoreId = '" + StoreId + "' and Enable = 1";
            
                string Tel = "";
                if (context.Request["Tel"] != null)
                {
                    Tel = context.Request["Tel"].ToString();
                    where = where + " and Tel like '%" + Tel + "%'";
                }

                
            
                str = "select * from SYS_User where 1 = 1 " + where;
                dt = sql.myDataSet(str).Tables[0];

                result.total = sql.GetCount("SYS_User", where);
            
				int len = dt.Rows.Count;
				if (len > 0)
				{
					for (int i = 0; i < len; i++) {
						SYS_User _SYS_User = new SYS_User();
						_SYS_User.Id = dt.Rows[i]["Id"].ToString();
                        _SYS_User.OpenId = dt.Rows[i]["OpenId"].ToString();
                        _SYS_User.StoreId = dt.Rows[i]["StoreId"].ToString();
                        _SYS_User.StoreFlg = dt.Rows[i]["StoreFlg"].ToString();
                        _SYS_User.Code = dt.Rows[i]["Code"].ToString();
                        _SYS_User.CompanyName = dt.Rows[i]["CompanyName"].ToString();
                        _SYS_User.Name = dt.Rows[i]["Name"].ToString();
                        _SYS_User.Sex = dt.Rows[i]["Sex"].ToString();
                        _SYS_User.Job = dt.Rows[i]["Job"].ToString();
                        _SYS_User.Tel = dt.Rows[i]["Tel"].ToString();
                        _SYS_User.AvatarUrl = dt.Rows[i]["AvatarUrl"].ToString();
                        _SYS_User.Email = dt.Rows[i]["Email"].ToString();
                        _SYS_User.Address = dt.Rows[i]["Address"].ToString();
                        _SYS_User.State = dt.Rows[i]["State"].ToString();
                        _SYS_User.Tocken = dt.Rows[i]["Tocken"].ToString();
                        _SYS_User.LoginTime = dt.Rows[i]["LoginTime"].ToString();
                        _SYS_User.CreateTime = dt.Rows[i]["CreateTime"].ToString();
                        _SYS_User.Enable = dt.Rows[i]["Enable"].ToString();
						SYS_UserList.Add(_SYS_User);
					}
					result.data = SYS_UserList;
					}

            }
            catch (Exception e1)
            {
                result.code = "0";
                result.msg = e1.Message;
            }
            unit.send(context, result);
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}

public class SYS_Userresult : result
{
    public List<SYS_User> data = new List<SYS_User>();
    public int total = 0;

}

public class SYS_User {
    public string Id = "";public string OpenId = "";public string StoreId = "";public string StoreFlg = "";public string Code = "";public string CompanyName = "";public string Name = "";public string Sex = "";public string Job = "";public string Tel = "";public string AvatarUrl = "";public string Email = "";public string Address = "";public string State = "";public string Tocken = "";public string LoginTime = "";public string CreateTime = "";public string Enable = "";
}
